package com.xyh.student.controller;


import javax.websocket.server.PathParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.xyh.student.entity.ResponseData;
import com.xyh.student.service.PaperService;

//@CrossOrigin
@RestController
@RequestMapping("/paper")
public class PaperController {

    @Autowired
    private PaperService paperService;

    // 懒人一键生成综合试卷，题目数量，paperId传入试卷的id，在新建试卷的时候必须输入试卷ID
    @GetMapping("/newAuto/{paperId}")
    public ResponseData newPaperAuto(@PathVariable("paperId") int paperId) {
        return paperService.newPaperByAuto(paperId);
    }

    //生成试卷输入试卷ID，以及选择的题库的lids，以及每种题型的数量
    @PostMapping("/new")
    public ResponseData newPaper(@PathParam("paperId") int paperId,@PathParam("lids") int[] lids,@PathParam("nums") int[] nums) {
        //nums题目数量
        //lids题库列表
        System.out.println(paperId+","+lids+","+nums);
        return paperService.newPaper(paperId,lids, nums);
    }

    //查找试卷列表
    @GetMapping("/list")
    public ResponseData findPaperList(){
        return paperService.findPaperList();
    }

    //查询一张试卷，需要传入paperId
    @GetMapping("/details/{paperId}")
    public ResponseData findPaperListDetails(@PathVariable("paperId") int paperId){
        return paperService.findPaperDetails(paperId);
    }

}
